const BASE_URL = "https://api.jidanyoupin.com/index.php/api"

function request({url, data, method}) {
      return new Promise((resolve, reject) => {
         //uni.app 发起网络请求
          uni.request({
              url: BASE_URL + url,
              data,
              method,
              sslVerify: true,
         		header: {
  				'content-type': 'application/x-www-form-urlencoded'
  			},
              success: ({
                  data,
                  statusCode,
                  header
              }) => {
                  if (data.code == 1){
                      resolve(data)
                  }else{
                     //请求失败 提示用户
                     //进行失败回调
                   reject(data.message);
                 }
             },
             fail: (errot) => {
                 //请求错误 直接进行错误回调
                     reject(errot);
             }
          })
      })
  }
  
 /*导出*/
 export default request;